package pers.lan.kafka.sample1.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import pers.lan.kafka.sample1.common.Foo1;

/**
 * @author <a href="mailto:1728209643@qq.com">lan</a>
 * @class pers.lan.kafka.sample1.controller.Controller
 * @date 2019-07-09 10:11
 */
@RestController
public class Controller {

    @Autowired
    private KafkaTemplate<Object, Object> template;

    @GetMapping(path = "/send/foo/{what}")
    public void sendFoo(@PathVariable String what) {
        this.template.send("topic1", new Foo1(what));
    }

    @GetMapping(path = "/send/foo2/{what}")
    public void sendFoSo(@PathVariable String what) {
        this.template.send("topic1.DLT", what);
    }
}
